forked from OneIdentity/PySafeguard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordExternalExample.py
More file actions
35 lines (24 loc) · 894 Bytes
/
Copy pathPasswordExternalExample.py
File metadata and controls
35 lines (24 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from pysafeguard import *
import json
# The appliance host name or IP address
hostName = ''
# The user name for password authentication
userName = ''
# The password for password authentication
password = ''
# Path to the trusted root ca of the appliance
caFile = ''
# The provider name or ID for external password authentication
externalProvider = ''
print('Connecting to Safeguard')
connection = PySafeguardConnection(hostName, caFile)
print('Getting external provider')
external = connection.get_provider_id(externalProvider)
print('Logging in')
connection.connect_password(userName, password, external)
print('Getting me')
result = connection.invoke(HttpMethods.GET, Services.CORE, 'Me')
print(json.dumps(result.json(),indent=2,sort_keys=True))
print('Getting login time remaining')
minutes_left = connection.get_remaining_token_lifetime()
print(f'Time remaining: {minutes_left}')